import sys
from typing import List


class Solution:
    def exist(self, target: int, nums: List):
        x1, x2 = -1, -1
        nums.sort()
        p1, p2 = 0, 1
        while p1<=p2 and p2<len(nums):
            if (nums[p2] - nums[p1]) == target:
                return nums[p1], nums[p2]
            elif (nums[p2] - nums[p1]) < target:
                p2 += 1
            else:
                p1 += 1
        return x1, x2


if __name__ == '__main__':
    line1 = sys.stdin.readline().strip()
    line2 = sys.stdin.readline().strip()

    n, m = list(map(int, line1.split()))
    weights = list(map(int, line2.split()))

    questions = []
    for i in range(m):
        line = sys.stdin.readline().strip()
        questions.append(int(line))

    for q in questions:
        x = Solution()
        x1, x2 = x.exist(q, weights)
        print(x1, x2)
